'use strict'

var config = require('../configs/db_config');
var Sequelize = require('sequelize');
var db = {
    sequelize: new Sequelize(config.sequelize.database, config.sequelize.username, config.sequelize.password, config.sequelize)
};
db.Topic = db.sequelize.import('../model/topic.js');
db.Activity = db.sequelize.import('../model/activity.js');
db.Dealer = db.sequelize.import('../model/dealer.js');
db.code = db.sequelize.import('../model/code.js');
db.Ac = db.sequelize.import('../model/ac.js');
db.Manager = db.sequelize.import('../model/manager.js');
db.Userwx = db.sequelize.import('../model/userwx.js');

db.declare = db.sequelize.import('../model/declare.js');

db.Activity.hasMany(db.Topic, {foreignKey: 'codeid', targetKey: 'code', as: 'Codeid'});

module.exports = db;